<?php

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Event;

class Index_ShowController extends BaseController
{

    /**
     * 商品订单列表
     */
    public function show()
    {    	
    	$vals 	= DB::table('index_law')
    			->select('img','title','home','desc','url')
    			->orderBy('seq')
    			->get();
    	    	
    	$data 	= $vals;
    	$val 	= [	'status_code' => 200, 'data' => $data ];    	    		
    	return json_encode($val);
    	
    }
    
	/**
     * 商品订单列表
     */
    public function good()
    {    	    	
    	$vals 	= DB::table('index_good')
    			->select('img','title','home','desc')
    			->orderBy('seq')
    			->get();
    	    	
    	$data 	= $vals;
    	$val 	= [	'status_code' => 200, 'data' => $data ];    	    		
    	return json_encode($val);
    	
    }
    
	/**
     * 会员卡接口
     */
    public function card()
    {    	    	
    	$vals 	= DB::table('index_card')
    			->select('img','price','title','p1','p2','p3','p4','p5','p6','p7')
    			->orderBy('seq')
    			->get();
    	
    	$data = [];
    	foreach($vals as $val){
    		$item		 	= [];
    		$item['img'] 	= $val->img;
    		$item['price'] 	= $val->price;
    		$item['title'] 	= $val->title; 
    		$desc = [];   		
    		for($i=1;$i<=7;$i++){
    			$p = 'p'.$i;
    			if(empty($val->$p)) break;
    			$desc[] = $val->$p;
    		}
    		$item['desc']	= $desc;
    		$data[]  		= $item;
    	}    	    	    	
    	$val 	= [	'status_code' => 200, 'data' => $data ];    	    		
    	return json_encode($val);    	
    }
}
